package com.gome.oa.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.TableRowSorter;

import com.gome.oa.custom.FormRowFilter;
import com.gome.oa.dialog.FillFormDialog;
import com.gome.oa.model.SelectType;

/**
 *
 * @author: tang li
 * @date: 2016年8月21日
 * @desc: 
 *
 */
public class DisplayTypeActionListener implements ActionListener {
	
	private JComboBox<SelectType> comboBoxSummary;
	private JTable tblForm;
	private FillFormDialog fillFormDialog;
	
	public DisplayTypeActionListener(JComboBox<SelectType> comboBoxSummary, JTable tblForm,
			FillFormDialog fillFormDialog) {
		super();
		this.comboBoxSummary = comboBoxSummary;
		this.tblForm = tblForm;
		this.fillFormDialog = fillFormDialog;
	}

	@Override
	public void actionPerformed(ActionEvent event) {
		if(comboBoxSummary.getSelectedItem().toString().equals("只显示加班")) {
			((TableRowSorter<?>) tblForm.getRowSorter()).setRowFilter(new FormRowFilter(false));
		}
		else {
			((TableRowSorter<?>) tblForm.getRowSorter()).setRowFilter(new FormRowFilter(true));
		}
		fillFormDialog.updateHours();
	}

}
